package com.stu.vertx.hello.verticle;

import com.stu.vertx.hello.handler.IndexHandle;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.ext.web.Router;

public class RequestDistribution06 extends AbstractVerticle {

    @Override
    public void start() throws Exception {

        // 创建HttpServer
        HttpServer server = vertx.createHttpServer();

        // 创建路由对象
        Router router = Router.router(vertx);


        // 监听/index地址
        router.route("/index").handler(new IndexHandle());

        // 把请求交给路由处理--------------------(1)
        server.requestHandler(router::accept);
        server.listen(8889);
    }

    public static void main(String[] args) {
        Vertx.vertx().deployVerticle(new RequestDistribution06());
    }
}
